//
// Created by TATO on 2025/8/22.
//

#include "http_tcp.h"

int tcp_conn_info(int fd, struct tcp_info *info)
{
    int tcp_len = sizeof (info);
    return getsockopt(fd, IPPROTO_TCP, TCP_INFO, info, (socklen_t*)&tcp_len);
}

int fd_is_connected(int fd)
{
    struct tcp_info info;
    tcp_conn_info(fd, &info);
    return (info.tcpi_state == TCP_ESTABLISHED) ? 1 : 0;
}